package com.tobeface.wechat.message.payload;

import com.tobeface.modules.lang.Requires;
import com.tobeface.wechat.message.WeChatMessageBuilder;
import com.tobeface.wechat.message.WeChatMessagePayloads;
import com.tobeface.wechat.message.WeChatMessageTypes;

import java.util.Map;

/**
 * @author loudyn
 */
public class ImageMessagePayloadBuilder extends AbstractMessagePayloadBuilder {

    private String picUrl;
    private String mediaId;

    /**
     * @param parent
     */
    public ImageMessagePayloadBuilder(WeChatMessageBuilder parent) {
        super(parent);
    }

    /**
     * @param picUrl
     * @return
     */
    public ImageMessagePayloadBuilder picUrl(String picUrl) {
        Requires.hasText(picUrl, "PicUrl must not be empty or null!");
        this.picUrl = picUrl;
        return this;
    }

    /**
     * @param mediaId
     * @return
     */
    public ImageMessagePayloadBuilder mediaId(String mediaId) {
        Requires.hasText(mediaId, "MediaId must not be empty or null!");
        this.mediaId = mediaId;
        return this;
    }

    @Override
    protected void configPayloads(Map<String, Object> payloads) {
        payloads.put(WeChatMessagePayloads.MSGTYPE_PAYLOAD, WeChatMessageTypes.IMAGE);
        payloads.put(WeChatMessagePayloads.PICURL_PAYLOAD, picUrl);
        payloads.put(WeChatMessagePayloads.MEDIAID_PAYLOAD, mediaId);
    }
}
